package com.sndscl.rpc.spring;

import com.sndscl.rpc.call.SndSclCall;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Author lsh
 * @Date 2020/10/16 14:10
 **/
@Component
public class ApplicationStartListener implements ApplicationListener<ContextRefreshedEvent> {

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        //TODO
        //web系统中会有两个容器，防止多次调用
        if(contextRefreshedEvent.getApplicationContext().getParent() == null){
            SndSclCall.init();
        }
    }

}
